package com.eazykitchen.util;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.eazykitchen.entity.UserInformation;
import org.springframework.stereotype.Service;

/*
* Token的工具类
* */
@Service
public class TokenUtil {
    /*
     * 根据用户名和密码，使用加密算法生成JWT的token令牌。
     * @param user
     * * @return */
    public static String getToken(UserInformation userInformation){
        String token ="";
        token= JWT.create()
                .withAudience(userInformation.getUserName()+"")
                .sign(Algorithm.HMAC256(userInformation.getUserPwd()));
        return token;
    }
}
